package com.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.service.DepServiceImpl;
import com.vo.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin("*")
public class DepController {


    @Autowired
    private DepServiceImpl depServiceImpl;

    @GetMapping("/findAllDep")
    public ResponseBean findAllDep()
    {
        List list = depServiceImpl.findALl();
        return new ResponseBean(0,0, list);
    }


    /**
     * 分页搜索查询
     * @param page   第几页
     * @param limit  页大小
     * @param depId  编号
     * @param depName 名称
     * @return
     */
    @RequestMapping("/searchDep")
    public ResponseBean search(@RequestParam(defaultValue ="1") int page, @RequestParam(defaultValue ="2") int limit, Integer depId, String depName)
    {
        IPage r = depServiceImpl.search(page,limit,depId,depName);
        return new ResponseBean(0, r.getTotal() , r.getRecords());
    }


}
